jaccard index two vectors R

44

jaccard index two vectors R -

jaccard <- function(M, user1, user2) {
  sums = rowSums(M[,c(user1, user2)])

  similarity = length(sums[sums==2])
  total = length(sums[sums==1]) + similarity
  
  similarity/total
}

Comments

Submit
0 Comments